// Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
#include "relu7_tiling_data.h"
#include "exe_graph/runtime/shape_utils.h"
#include "log/op_log.h"
#include "register/op_impl_registry.h"

namespace optiling
{
    struct Relu7OpCompileInfo
    {
        int coreNum;
        int ubSize;
    };

    template <typename T>
    static void AppendTilingData(gert::TilingData *tilingData, T value)
    {
        tilingData->Append<T>(value);
    }

    ge::graphStatus Relu7TilingPrepare(gert::TilingParseContext *context)
    {
        OP_LOGD(context->GetNodeName(), "Relu7TilingPrepare enter.");
        return ge::GRAPH_SUCCESS;
    }

    ge::graphStatus Relu7Tiling(gert::TilingContext *context)
    {
        auto tilingData = context->GetTilingData<optiling::Relu7TilingData>();
        if (tilingData == nullptr)
        {
            OP_LOGE(context->GetNodeName(), "optiling::Relu7TilingData is null in context");
            return ge::GRAPH_FAILED;
        }

        auto inShape = context->GetInputShape(0);
        if (inShape == nullptr)
        {
            OP_LOGE(context->GetNodeName(), "InputShape[0] is null in context");
            return ge::GRAPH_FAILED;
        }

        const auto &inShapeValue = gert::EnsureNotScalar(inShape->GetStorageShape());
        auto shapeSize = inShapeValue.GetShapeSize();
        auto inTensor = context->GetInputTensor(0);
        auto dataTypeSize = ge::GetSizeByDataType(inTensor->GetDataType());
        // todo fill tilingData

        context->SetBlockDim(tilingData->coreNum);
        OP_LOGE(context->GetNodeName(), "ReluTilingConstruct success");
        return ge::GRAPH_SUCCESS;
    }

    IMPL_OP(Relu7).Tiling(Relu7Tiling).TilingParse<Relu7OpCompileInfo>(Relu7TilingPrepare);
}